在服务器端判断表单是否重复提交,主要可以考虑在页面之间通过Session共享标志变量的方法来实现,即在客户端页面设置Session中的标志变量,然后在服务器段对Session中的标志变量进行判断。
1.新建一个ServerTest.jsp文件,代码如下:
<%@ page language="java" contentType="text/html; charset=Gb2312"
pageEncoding="Gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>提交页面</title>
</head>
<%
//设置标志变量SubmitFlag值ServerTest.jsp
session.putValue("SubmitFlag","ServerTest.jsp");
%>
<body bgcolor="#ffffff">
<form name="form_client" action="ServerSubmit.jsp">
<input type="checkbox" name="check_1" checked=true/>人在江湖
<input type="submit" name="submitok"/>
</form>
</body>
</html> |